import request from '@/util/request'

// 获取他为我未采纳列表
export function listMainCart(pageParams, data) {
  const { index, size } = pageParams
  const { childId, orderBatch } = data
  return request({
    url: `/otherPushToMe/list/${index}/${size}.json`,
    method: 'get',
    headers: {
      childId: childId,
      orderBatch: orderBatch
    },
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取子账号列表
export function listChildAccount() {
  return request({
    url: '/otherPushToMe/listPushedChild.json',
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 清除授权关系已解除的预选单
export function clearPreOrder() {
  return request({
    url: '/otherPushToMe/hidePushMainBatch.json',
    method: 'post',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取我为他未采纳详情主要信息
export function getPushMainDetail(orderBatch) {
  return request({
    url: `/otherPushToMe/mainDetail/${orderBatch}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取我为他未采纳详情商品信息
export function listProductDetail(orderBatch) {
  return request({
    url: `/otherPushToMe/listPushProduct/${orderBatch}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 删除预选单
export function deletePushMain(orderBatch) {
  return request({
    url: `/otherPushToMe/deletePushMain/${orderBatch}.json`,
    method: 'delete',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取审批记录列表
export function listApprove(pagaParams, orderBatch) {
  const { index, size } = pagaParams
  return request({
    url: `/otherPushToMe/listApprove/${orderBatch}/${index}/${size}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 计算运费
export function freight(data) {
  return request({
    url: 'otherPushToMe/freight.json',
    method: 'POST',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 修改商品数量
export function amount(data) {
  return request({
    url: 'otherPushToMe/amount.json',
    method: 'PATCH',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 修改地址
export function updateAddress(data, orderBatch, path) {
  return request({
    url: `otherPushToMe/updateAddress/${orderBatch}/${path}.json`,
    method: 'PATCH',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 批量删除商品
export function deletes(ids) {
  return request({
    url: `otherPushToMe/${ids}.json`,
    method: 'DELETE',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 删除预选单
export function deletePreOrder(orderBatch) {
  return request({
    url: `otherPushToMe/deletePreOrder/${orderBatch}.json`,
    method: 'DELETE',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取他为我选单数量
export function getPreOrderCount() {
  return request({
    url: '/otherPushToMe/getPreOrderCount.json',
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}
